//graham matuszewski
#pragma once

#ifndef FEEDERTEST_H_
#define FEEDERTEST_H_

#include <iostream>
#include "Enums.h"
#include "Structs.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "Agent.h"
#include "GantryAgentMock.h"
//#include "GUIFeederMock.h"
#include "FeederAgent.h"
#include "Feeder.h"
#include "LaneAgentMock.h"
//#include "GUIFeederMock.h"
#include <string>
//test of the feeder



class FeederTest : public ::testing::Test {
public:
	FeederTest() : feeder("Feeder Test"){

	}


	FeederAgent feeder;
	LaneAgentMock bottomLaneMock;
	LaneAgentMock topLaneMock;
	GantryAgentMock gantryMock;


	virtual void SetUp() {
		feeder.setGantry(&gantryMock);
		feeder.setLaneBottom(&bottomLaneMock);
		feeder.setLaneTop(&topLaneMock);
		feeder.setGUIFeeder(NULL);

	}

	bool isGuiStarted() {
		return false;
	}

	bool isPurgeHappening(){
		return false;
	}

	bool runScheduler(){
		return feeder.pickAndExecuteAnAction();
	}
	Gantry* getGantryFromFeeder(){
		return feeder.getGantryAgent();
	}
	
	Lane* getBottomFromFeeder(){
		return feeder.getBottomAgent();
	}
	Lane* getTopFromFeeder(){
		return feeder.getTopAgent();
	}

	int getPartsOrdersSizeFromFeeder(){
		return feeder.partOrdersSize();
	}
	
	void print(std::string text){
		std::cout << "feeder " << ": " << text << std::endl;
	}
	
};
//init test

TEST_F(FeederTest, InitialTest){

	EXPECT_FALSE(isGuiStarted());
	
	EXPECT_FALSE(isPurgeHappening());

}



//set lanes and gantry
TEST_F(FeederTest, setLanes){
	//feeder.setGantry(gantryMock);
	//feeder->setLaneBottom(&bottomLaneMock);
	//feeder->setLaneTop(&topLaneMock);
	EXPECT_EQ(&gantryMock,getGantryFromFeeder());
	EXPECT_EQ(&bottomLaneMock,getBottomFromFeeder());
	EXPECT_EQ(&topLaneMock,getTopFromFeeder());
}
TEST_F(FeederTest, oneMessageToFeeder){
	PartType temp;
	temp=A;
	//EXPECT_CALL(feeder,msgPleaseGetParts(temp,&bottomLaneMock));
	feeder.msgPleaseGetParts(temp,&bottomLaneMock);
	EXPECT_EQ(1,getPartsOrdersSizeFromFeeder());
	EXPECT_CALL(gantryMock,msgPleaseGetParts(feeder.getTopRecipe(),&feeder));
	//gantryMock.msgPleaseGetParts(tempRecipe,&feeder);
	feeder.pickAndExecuteAnAction();
	//EXPECT_TRUE(runScheduler());
	

}
TEST_F(FeederTest, twoMessageToFeeder){
	PartType temp;
	temp=A;
	//EXPECT_CALL(feeder,msgPleaseGetParts(temp,&bottomLaneMock));
	feeder.msgPleaseGetParts(temp,&bottomLaneMock);
	EXPECT_EQ(1,getPartsOrdersSizeFromFeeder());
	EXPECT_CALL(gantryMock,msgPleaseGetParts(feeder.getTopRecipe(),&feeder));
	PartRecipe goodRecipe = feeder.getTopRecipe();
	//gantryMock.msgPleaseGetParts(tempRecipe,&feeder);
	//feeder.pickAndExecuteAnAction();
	runScheduler();
	//goodRecipe.topLane=false;
	feeder.msgHereAreParts(goodRecipe);
	EXPECT_CALL(bottomLaneMock, msgHereAreParts(goodRecipe.partType));
	//feeder.pickAndExecuteAnAction();
	
	runScheduler();


	//runScheduler();
	//EXPECT_TRUE(runScheduler());
}








TEST_F(FeederTest, justForDebug){
	//std::getchar();
}



#endif